import { defineConfig } from "vite";
import { fileURLToPath, URL } from "node:url";
import { envParse } from "vite-plugin-env-parse";
import vue from "@vitejs/plugin-vue";
import path from "node:path";
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), envParse({})],
  server: {
    cors: true,
    open: true,
    port: 5199,
    proxy: {
      "/api": {
        target: "http://karrysmile.top:8100/api", // 设置代理目标
        changeOrigin: true, // 是否改变请求源地址
        rewrite: (path) => path.replace(/^\/api/, ""), // 将 /api 替换为空字符串
      },
    },
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
    extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
  },
  envPrefix: "APP_",
});
